import axios from './init'
import { good, Limit } from '@/store/goods/interface'
import qs from 'qs'

/**
 * @function
 */

export const getAllGoods = async (limit:Limit) => {
  const { data } = await axios.get(`goods?${qs.stringify(limit)}`)
  return data
}

export const deleteGood = async (id:number) => {
  const { data } = await axios.delete('goods/' + id)
  return data
}

export const modifyGoods = async (data:good) => {
  const { data: res } = await axios.put('goods/' + data.goods_id, data)
  return res
}

export const searchGoodById = async (id:number) => {
  const { data } = await axios.get(`goods/${id}`)
  return data
}
